package com.dd.cloud.user.service.admin.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dd.cloud.common.interceptor.UserInterceptor;
import com.dd.cloud.common.vo.LoginInfo;
import com.dd.cloud.user.entity.admin.ProblemHelpClick;
import com.dd.cloud.user.mapper.admin.ProblemHelpClickMapper;
import com.dd.cloud.user.service.admin.IProblemHelpClickService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

/**
 * @author Lx
 * @version 1.0
 * @date 2023/9/18
 */
@Slf4j
@Service
public class ProblemHelpClickServiceImpl extends ServiceImpl<ProblemHelpClickMapper, ProblemHelpClick> implements IProblemHelpClickService {
    /**
     * 问题点击[有用/没用]按钮
     *
     * @param type
     * @param problemId
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void problemHelpClick(Integer problemId, Integer type) {
        LoginInfo loginInfo = UserInterceptor.getLoginUserInfo(LoginInfo.UserType.DOCTOR).get();
        ProblemHelpClick phc = new ProblemHelpClick();
        phc.setProblemId(problemId);
        phc.setType(type);
        phc.setDocId(loginInfo.getId());
        phc.setStatus(1);
        phc.setCreateDate(LocalDateTime.now());
        save(phc);
    }
}
